<?php

function print_log($msg)
{

    $localtime = getdate();
    $cyear = $localtime["year"];
    $cmonth = $localtime["mon"];
    $cday = $localtime["mday"];
    $chour = $localtime["hours"];
    $cmin = $localtime["minutes"];
    $csec = $localtime["seconds"];

    $timestamp = "$cyear-$cmonth-$cday $chour:$cmin:$csec";

    $LOG = $_SERVER['DOCUMENT_ROOT']."/allen/log/${cyear}";
    if (!@mkdir($LOG, 0777, true) && !@is_dir($LOG) ){ return false; }

    $LOG .= "/${cmonth}.log";
    if ( !($fp = @fopen($LOG, "a+")) ){ return false; }
    if ( flock($fp, LOCK_EX) ) {
        @chown($LOG, 777);
        fwrite($fp, "${timestamp}: $msg\n");
        flock($fp, LOCK_UN);
    }
    fclose($fp);
    return true;
}

?>

